<?php
  require_once('tpl/header.php');
?><?php 
      require_once("loginCheckadmin.php");
      require_once("../system/dbConn.php");
 
     ?>
  <form action="">
    	<input type="text" name="key">
    	<input type="submit" value="搜索">
    </form>

 

	<?php 
	//连接数据库：读取users表中的所有记录，显示到表格中



	$sql = "select * from users";
    
    if(isset($_GET["key"])){ 
       $key=trim($_GET["key"]);
       $sql="select * from users where username like '%{$key}%'";
    }
    
	$result = mysqli_query($link,$sql);
//结果集
	$num = mysqli_num_rows($result);
	if($num==0){
		echo "没有记录，请重新输入";
		exit();
	}
	?>
	<table class="table table-bordered" align="center" width="60%">
		<caption>注册用户信息列表（共 <?php echo $num ?> 名用户）</caption>
		<tr>
			<th width="15%">用户编号</th>
			<th width="15%">用户名</th>
			<th width="10%">性别</th>
			<th width="20%">生日</th>
			<th width="10%">头像</th>
			<th width="20%">电子邮件</th>
			<th width="10%">操作</th>
		</tr>
	<?php
	while ($row = mysqli_fetch_assoc($result)) {
	?>
		<tr>
			<th><?php echo $row["uid"]; ?></th>
			<th><?php echo $row["username"] ?></th>
			<th>
				<?php 
				// echo $row["gender"];
				if ($row["gender"] == 0) {
					echo "男";
				}else{
					echo "女";
				}
				?>		
			</th>
			<th><?php echo $row["birthdate"] ?></th>
			<th><img src="../images/<?php echo $row["pic"] ?>" alt="头像" width="80" height="80"></th>
			<th><?php echo $row["email"] ?></th>
			<th><a href="doUserDelete.php?uid=<?php echo $row["uid"];?>" 
				onclick="return confirm('真的删除吗?')">删除</a></th>
		</tr>
	<?php	
	}
	 	?>
		</table>
	</form>
   


<?php
  require_once('tpl/footer.php');
?>